Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Improve caching glue performance #2971

Merged
merged 13 commits into from
Feb 25, 2025
Merged

[Core] Improve caching glue performance #2971

merged 13 commits into from
Feb 25, 2025

Conversation

jkronegg
Copy link
Contributor

@jkronegg jkronegg commented Feb 1, 2025

🤔 What's changed?

The CachingGlue performance has been improved by caching the following elements:

  • parameter types
  • data table types
  • docString types
  • step definitions

The cache is invalidated when a parameter type or a step definition is added/removed, or when the language changes.
The cache is not used when scenario-scoped glue is present (e.g. cucumber-java8).

⚡️ What's your motivation?

This improves the CachingGlue performance.

On a personal project with about 250 step definitions and 1000 test scenarios, the performance is the following:

Version Test duration
7.20.1 (original) 8.2 seconds
7.21.0-SNAPSHOT (this PR) 3.4 seconds (2.4x faster)

🏷️ What kind of change is this?

  • ⚡ New feature (non-breaking change which adds new behaviour)

♻️ Anything particular you want feedback on?

I'm not 100% sure about whether cucumber-java8 has still the same behavior, but at least the unit tests did not change.
I accidentally deleted the original PR, sorry.

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

@jkronegg jkronegg marked this pull request as draft February 1, 2025 01:08
jkronegg pushed a commit that referenced this pull request Feb 1, 2025
@mpkorstanje mpkorstanje self-requested a review February 1, 2025 07:28
jkronegg pushed a commit that referenced this pull request Feb 1, 2025
@jkronegg jkronegg marked this pull request as ready for review February 1, 2025 07:29
jkronegg pushed a commit that referenced this pull request Feb 1, 2025
Copy link
Contributor

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Technically this looks way more manageable then I expected.

To keep the scope of this PR manageable, I think it would be prudent to initially always consider the cache dirty in the presence of ScenarioScoped glue code.

It means we won't get the performance gains for cucumber-java8 but we can then look removing ScenarioScoped from cucumber-java8 separately. If there are other backends that do use ScenarioScoped glue, they can either stop using that or contribute the next improvement.

@jkronegg jkronegg force-pushed the faster-caching-glue branch from 27d5201 to f3efd5d Compare February 3, 2025 07:40
@mpkorstanje mpkorstanje self-requested a review February 9, 2025 16:55
@mpkorstanje mpkorstanje mentioned this pull request Feb 15, 2025
7 tasks
@mpkorstanje
Copy link
Contributor

TODO:

Copy link
Contributor

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for doing the initial leg work.

This also had a positive knock on effect on the number of messages created by Cucumber. Because we're reusing step definitions they don't need to be redefined for each scenario.

So that's an improvement of # scenarios * # step definitions to just # step definitions.

@mpkorstanje mpkorstanje changed the title Faster caching glue [Core] Improve caching glue performance Feb 25, 2025
@mpkorstanje mpkorstanje self-requested a review February 25, 2025 00:23
@mpkorstanje mpkorstanje merged commit 20ec82a into main Feb 25, 2025
6 checks passed
@mpkorstanje mpkorstanje deleted the faster-caching-glue branch February 25, 2025 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants